<script type="text/javascript" src="<?php echo base_url(); ?>static/select2/select2.min.js" ></script>
<script type="text/javascript" src="<?php echo base_url(); ?>static/js/selectSearchGlobal.js"></script>
<!--
<link type="text/css" href="<?php echo base_url(); ?>ajaxupload/ajaxfileupload.css" rel="stylesheet" /> 
<script src="<?php echo base_url(); ?>ajaxupload/jquery.js" type="text/javascript"></script>
<script src="<?php echo base_url(); ?>ajaxupload/ajaxfileupload.js" type="text/javascript"></script>
-->

<script>
//SCRIPT INI HARUS DIATAS, TIDAK BOLEH DIBAWAH
$("#r_name").change(function()
{
    //alert(this.id.substr(2));    
	var nik = $(this).val();
	var DataString = {id:nik};
	$.ajax({
			type: "POST",
			url : "<?php echo site_url('search_global/globals_nik_detail')?>",
			dataType: 'json',
			data: DataString,
			success: function(data)
			{
				$("#r_id").val(data.DetailEmp.HR_ID);
                $("#r_nama").val(data.DetailEmp.NAME);
                $("#r_mgrid").val(data.DetailEmp.MANAGER_ID);
				$("#r_mgr").val(data.DetailEmp.MANAGER);
				$("#r_dept").val(data.DetailEmp.ORG);
				$("#r_job").val(data.DetailEmp.JOB_POSITION);														
			}
			
		});
});
</script>

<?php /*
    $pParkirdId	=	$HTTP_GET_VARS['pParkirdId'];
	$pStatus	=	$HTTP_GET_VARS['pStatus'];
	$pReqId		=	$HTTP_GET_VARS['pReqId'];
	$pReqDetId	=	$HTTP_GET_VARS['pReqDetId'];
	$pNikFor	=	$HTTP_GET_VARS['pNikFor'];

	if(!empty($pNikFor)){
	    $qry0 = "select id, name, org, job_position, status, to_char(contract_sdate,'dd/mm/yyyy') contract_sdate, to_char(contract_edate,'dd/mm/yyyy') contract_edate from hrs where id='$pNikFor'";
	    $DB->parse($qry0);
		$DB->execute();
		if(	$b=$DB->nextrow()){
			$aParkirdUntukNik  	= $b["ID"];
			$cName  = $b["NAME"];
			$cOrg  	= $b["ORG"];
			$cJob  	 = $b["JOB_POSITION"];
			$aParkirdUseBy  		 = $b["STATUS"];
			$aContractSdate  = $b["CONTRACT_SDATE"];
			$aContractEdate  = $b["CONTRACT_EDATE"];
		}
	}*/
    
	foreach($getDetail as $a){
		$aParkirdNik  		= $a["PARKIRD_NIK"];
		$aParkirdUntukNik  	= $a["PARKIRD_UNTUK_NIK"];
		$aParkirdAtasanNik  = $a["PARKIRD_ATASAN_NIK"];
		$aParkirdType  		= $a["PARKIRD_TYPE"];
		$aParkirdPlat  		= $a["PARKIRD_PLAT"];
		$aParkirdStnk  		= $a["PARKIRD_STNK"];
		$aParkirdDate  		= $a["PARKIRD_DATE"];
		$aParkirdDescription= $a["PARKIRD_DESCRIPTION"];
		$aParkirdFile  		= $a["PARKIRD_FILE"];
		$aParkirdUseBy  	= $a["PARKIRD_USE_BY"];
		$aParkirdType1  	= $a["PARKIRD_TYPE_1"];
		$aParkirdPlat1  	= $a["PARKIRD_PLAT_1"];
		$aParkirdStnk1  	= $a["PARKIRD_STNK_1"];
		$aParkirdFlag1  	= $a["PARKIRD_FLAG_1"];
		$aParkirdType2  	= $a["PARKIRD_TYPE_2"];
		$aParkirdPlat2  	= $a["PARKIRD_PLAT_2"];
		$aParkirdStnk2  	= $a["PARKIRD_STNK_2"];
		$aParkirdFlag2  	= $a["PARKIRD_FLAG_2"];
		$aParkirdType3  	= $a["PARKIRD_TYPE_3"];
		$aParkirdPlat3  	= $a["PARKIRD_PLAT_3"];
		$aParkirdStnk3  	= $a["PARKIRD_STNK_3"];
		$aParkirdFlag3  	= $a["PARKIRD_FLAG_3"];
		$aParkirdType4  	= $a["PARKIRD_TYPE_4"];
		$aParkirdPlat4  	= $a["PARKIRD_PLAT_4"];
		$aParkirdStnk4  	= $a["PARKIRD_STNK_4"];
		$aParkirdFlag4  	= $a["PARKIRD_FLAG_4"];
		$aContractSdate  	= $a["CONTRACT_SDATE"];
		$aContractEdate  	= $a["CONTRACT_EDATE"];

		$aParkirdAtasanName = $a["ATASANNAME"];
		$cName				= $a["NIKNAME"];
		$cJob				= $a["NIKJOBPOSITION"];
		$cOrg				= $a["NIKORG"];

		if($aParkirdFlag1 == 'Y'){
		   $cFlag1 = "checked";
		   $cFlag2 = "";
		   $cFlag3 = "";
		}
        else if($aParkirdFlag2 == 'Y'){
		   $cFlag1 = "";
		   $cFlag2 = "checked";
		   $cFlag3 = "";
		}
        else if($aParkirdFlag3 == 'Y'){
		   $cFlag1 = "";
		   $cFlag2 = "";
		   $cFlag3 = "checked";
		}

	}
    /*
	if(empty($org)){
		   $org = dbora_getorg("$nik");
	}*/
?>

<div id="top" >
<form id="formarea" role="form" method="post" action="<?php echo site_url();?>search_global/edit_reqSave" class="form-horizontal"  enctype="multipart/form-data"> 
<input type="hidden" value="<?php echo $cRequestNo; ?>" id="pCtrlID" name="pCtrlID" />
    <input type="hidden" value="<?php echo $cType; ?>" id="pCType" name="pCType"/>
<!--<div class="container">-->
	<div class="col-md-offset-0">
		<div class="col-md-11">
            <!--
            <div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> User Login</b></h4></div>
				<div class="panel-body">
                
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">NIK</label>
							<div class="col-md-7"><input type="text" value="<?php echo $sesNik;?>" id="pNik" name="pNik" class="select2 form-control input-sm" /></div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7"><input type="text" value="<?php echo $sesName;?>" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7"><input type="text" value="<?php echo $sesOrg;?>" class="form-control input-sm" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8"><input type="text" value="<?php echo $sesJob;?>" class="form-control input-sm" readonly=""/></div>
						</div>
					</div>
                    
                    <?php
					if($aParkirdUseBy == 'CONTRACT'){
					?>
                    <div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">DeStatus Kerja</label>
							<div class="col-md-7">
                            <input type="text" id="pStatusFor" name="pStatusFor" value="<?php echo $aParkirdUseBy;?>" class="form-control input-sm" readonly=""/></div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Jangka Waktu</label>
							<div class="col-md-8">
                                <input type="text" id="pSdate" name="pSdate" value="<?php echo $aContractSdate;?>" class="form-control input-sm" readonly=""/>
                                <input type="text" id="pEdate" name="pEdate" value="<?php echo $aContractEdate;?>" class="form-control input-sm" readonly=""/>
                            </div>
						</div>
					</div>              
					<?php
					}
					?>
				</div>
			</div>
            -->
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Request By</b></h4></div>
				<div class="panel-body">
					<div class="col-xs-12 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-3">Nama</label>
							<div class="col-md-7">
                                <input type="hidden" class="select2 form-control input-sm" id="r_nama" name="r_nama" value="<?php echo $cName;?>" readonly=""/>
								<input type="text" class="select2 form-control input-sm" id="r_name" name="r_name" placeholder="<?php echo $cName;?>"/>
							</div>
						</div>					
						<div class="form-group">
							<label class="control-label col-md-3">Nik</label>
							<div class="col-md-3">
								<input type="text" class="form-control input-sm" id="r_id" name="r_id" value="<?php echo $aParkirdUntukNik;?>" readonly=""/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-3">Nama Atasan</label>
							<div class="col-md-7">
                                <input id="r_mgrid" name="r_mgrid" type="hidden" value="<?php echo $aParkirdAtasanNik;?>"/>
								<input type="text" class="form-control input-sm" id="r_mgr" name="r_mgr" value="<?php echo $aParkirdAtasanName;?>" readonly=""/>
							</div>
						</div>
					</div>
					<div class="col-sm-7 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-4">Departement</label>
							<div class="col-md-7">
								<input type="text" class="form-control input-sm" id="r_dept" name="r_dept" value="<?php echo $cOrg;?>" readonly=""/>
							</div>
						</div>
						<div class="form-group">
							<label class="control-label col-md-4">Job Position</label>
							<div class="col-md-8">
								<input type="text" class="form-control input-sm" id="r_job" name="r_job" value="<?php echo $cJob;?>" readonly=""/>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading"><h4 class="panel-title"><b class="caret"></b><b> Form</b></h4></div>
				<div class="panel-body">
					<div class="col-sm-6 col-md-6">
						<div class="form-group">
							<label class="control-label col-md-2">Vehicle</label>
							<div class="col-md-10">
								<div class="radio"><label><input type="radio" id="vchoose1" name="v_car" onclick="CheckThis(1)" checked="checked"/><label> Car</label></div>	
								<div class="table-responsive">
								<table class="table table-bordered table-condensed table-striped">
									<thead>
										<tr>
											<th class="tblhead" style="width:5%;text-align:center">No.</th>
											<th class="tblhead" style="width:25%;text-align:center">Vehicle License</th>
											<th class="tblhead" style="width:40%;text-align:center">Vehicle Number Certificate</th>
											<th class="tblhead" style="width:5%;text-align:center">Active</th>
										</tr>
									</thead>
									<tbody>
										<tr>
											<td style="text-align:center">1</td>
											<td>
												<input type="text" id="NoLcs1" class="form-control input-sm" name="License1" value="<?php echo $aParkirdPlat1;?>" 
												autocomplete="off"/>
											</td>
											<td>
												<input type="text" id="NoCert1" class="form-control input-sm" name="Certificate1" value="<?php echo $aParkirdStnk1;?>" 
												autocomplete="off"/>
												</td>
											<td style="text-align:center">
                                                <input type="radio" id="NoRadio1" value="1" name="CarRadio" <?php if($aParkirdFlag1=='Y'){?>checked=""<?php } ?>/>
                                            </td>
										</tr>
										<tr>
											<td style="text-align:center">2</td>
											<td>
												<input type="text" id="NoLcs2" class="form-control input-sm" name="License2" value="<?php echo $aParkirdPlat2;?>" 
												autocomplete="off"/>
											</td>
											<td>
												<input type="text" id="NoCert2" class="form-control input-sm" name="Certificate2" value="<?php echo $aParkirdStnk2;?>" 
												autocomplete="off"/>
											</td>
											<td style="text-align:center">
                                            <input type="radio" id="NoRadio2" value="2" name="CarRadio" <?php if($aParkirdFlag2=='Y'){?>checked=""<?php } ?>/>
                                            </td>
										</tr>
										<tr>
											<td style="text-align:center">3</td>
											<td>
												<input type="text" id="NoLcs3" class="form-control input-sm" name="License3" value="<?php echo $aParkirdPlat3;?>" 
												autocomplete="off"/>
											</td>
											<td>
												<input type="text" id="NoCert3" class="form-control input-sm" name="Certificate3" value="<?php echo $aParkirdStnk3;?>" 
												autocomplete="off"/>
												</td>
											<td style="text-align:center">
                                                <input type="radio" id="NoRadio3" value="3" name="CarRadio" <?php if($aParkirdFlag3=='Y'){?>checked=""<?php } ?>/>
                                                </td>
										</tr>
									</tbody>
								</table>
								</div>
							</div>
						</div>
					</div>
					<div class="col-sm-6 col-md-6">
						<div class="form-group">
							<div class="col-md-10">
								<div class="radio"><label>
                                <input type="radio" id="vchoose2" name="v_motor" onclick="CheckThis(2)">Motor</label></div>
								<div class="table-responsive">
								<table class="table table-bordered table-condensed table-striped">
									<thead>
										<tr>
										<th class="tblhead" style="width:5%;text-align:center">No.</th>
										<th class="tblhead" style="width:25%;text-align:center">Police Number</th>
										<th class="tblhead" style="width:40%;text-align:center">License Number</th>
										<th class="tblhead" style="width:5%;text-align:center">Active</th>
										</tr>
									</thead>
									<tbody>
										<tr>
										<td style="text-align:center">1</td>
										<td style="text-align:center"><input type="text" id="NoLcs4" name="License4" class="form-control input-sm" disabled="disabled"/></td>
										<td style="text-align:center"><input type="text" id="NoCert4" name="Certificate4" class="form-control input-sm" disabled="disabled"/></td>
										<td style="text-align:center"><input type="radio" id="NoRadio4" value="4" name="MotorRadio4" disabled="disabled"></td>
										</tr>
									</tbody>
								</table>
								</div>
							</div>
						</div>
						<div class="form-group">
							<div class="col-md-9"><small><b>Vehicle License : <span>xx(spasi)1234(spasi)xxx</span></b></small></div>
							<div class="col-md-10">
								<small>
									<span style="color:#FF0000">xx </span>(1-2 Alphabet) 
									<span style="color:#FF0000">1234 </span>(1-4 Number) 
									<span style="color:#FF0000">xxx </span>(1-3 Alphabet)
								</small>
							</div>
						</div>
					</div>
					<div class="col-sm-6 col-md-7">
						<div class="form-group">
							<label class="control-label col-md-2">Description</label>
							<div class="col-md-7">
								<textarea id="pDescription" name="pDescription" class="form-control" rows="4"><?php echo $aParkirdDescription;?></textarea>
							</div>
						</div>
                        <div class="form-group">
							<label class="control-label col-md-7">File Uploaded</label>
							<div class="col-md-5"><label class="control-label col-md-7"><?php echo $aParkirdFile;?></label></div>
						</div>
                        
						<div class="form-group">
							<label class="control-label col-md-7">Upload Photo of License Number</label>
							<div class="col-md-5"><input id="file" type="file" name="file" class="control-label"/></div>
						</div>
					</div>
					<div class="col-md-11" style="margin-top:40px;">
						<div class="form-group" style="text-align:center">
							<div class="col-sm-2">
                            
								<input type="submit" value="Save This Form" name="submit" class="btn btn-md btn-success" />
                                <!--<button type="button" class="btn btn-success btn-block" onclick="editSrnKrjPrkSave();" >Submit</button>-->
							</div>
                            <div class="col-sm-2">
                                <button type="button" class="btn btn-default btn-block" onclick="cancel();" >Finish</button>
                            </div>
						</div>					
					</div>
				</div>
			</div>
		</div>
	</div>
<!--</div>-->
</form>
</div>

<script>
function CheckThis(VChoose)
{
	var i = 1;
	if(VChoose == '1')
	{
		for (i=1;i<4;i++)
		{
			var vc1 = document.getElementById('vchoose1');
			var Pol = document.getElementById('NoLcs'+i);
			var Stnk = document.getElementById('NoCert'+i);
			var Radio = document.getElementById('NoRadio'+i);
			Pol.disabled = false;Stnk.disabled = false;Radio.disabled = false;vc1.checked = true;
		}
		var vc2 = document.getElementById('vchoose2');
		var Pol = document.getElementById('NoLcs4');
		var Stnk = document.getElementById('NoCert4');
		var Radio = document.getElementById('NoRadio4');
		Pol.disabled = true;Stnk.disabled = true;Radio.disabled = true;vc2.checked = false;Radio.checked = false;
		Pol.value = '';Stnk.value = '';Radio.value = '';		
	}
	if(VChoose == '2')
	{
		for (i = 1;i<4;i++)
		{
			var vc1 = document.getElementById('vchoose1');
			var Pol = document.getElementById('NoLcs'+i);
			var Stnk = document.getElementById('NoCert'+i);
			var Radio = document.getElementById('NoRadio'+i);
			Pol.disabled = true;Stnk.disabled = true;Radio.disabled = true;vc1.checked=false;Radio.checked = false;
			Pol.value = Pol.value;Stnk.value = Stnk.value;Radio.value = '';
		}
		var vc2 = document.getElementById('vchoose2');
		var Pol = document.getElementById('NoLcs4');
		var Stnk = document.getElementById('NoCert4');
		var Radio = document.getElementById('NoRadio4');
		Pol.disabled = false;Stnk.disabled = false;Radio.disabled = false;vc2.checked=true;
	} 
}
</script>
